package com.iflytek.universitymanagement.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface StatisticsMapper extends BaseMapper<Object> {

    // 查询学生总数
    @Select("SELECT COUNT(*) FROM student")
    int getStudentCount();

    // 查询课程总数
    @Select("SELECT COUNT(*) FROM course")
    int getCourseCount();

    // 查询竞赛参与总数
    @Select("SELECT COUNT(DISTINCT student_id) FROM student_competition WHERE participation_status = '参加'")
    int getCompetitionParticipationCount();

//    // 查询平均完成率（示例：根据课程进度计算）
//    @Select("SELECT AVG(complete_rate) FROM student_course_progress") // 假设有`student_course_progress`表
//    Double getAverageCompletionRate();

  //  查询平均完成率（示例：根据课程进度计算）
  @Select("SELECT AVG(CAST(REPLACE(progress, '%', '') AS DECIMAL)) FROM student_score")
  Double getAverageCompletionRate();

}

